package com.kashi.mapper;

import com.kashi.pojo.Goods;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsMapper {
    //按关键词、类别搜索商品
    @Select("SELECT * FROM goods WHERE name LIKE CONCAT('%', #{keyword}, '%')"
            + "<if test='category != null'> AND category = #{category}</if>")
    List<Goods> list(String keyword, String category);

    //按商品id查询
    @Select("SELECT * FROM goods WHERE id = #{id}")
    List<Goods> getById(Integer id);
}